package com.wm.problemrecyclerview

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.ctetin.expandabletextviewlibrary.ExpandableTextView

/**
 * author: wu-meng
 * date  : 2024/1/11
 * desc  :
 */
class MainAdapter() : RecyclerView.Adapter<MainAdapter.ViewHolder>() {

    private var mData = mutableListOf<String>()

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.layout_item,parent,false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mData.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.textView.setContent(mData[position])
    }

    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val textView : ExpandableTextView = itemView.findViewById(R.id.tv_remarks)
    }

    fun setData(data: MutableList<String>) {
        this.mData = data
    }

}